import Vue from 'vue'
import Router from 'vue-router'


Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

export const constantRouterMap = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path:'/studentNomal',
    component:() => import('@/views/studentNomal'),
    hidden:true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },

  {
    path: '/info',
    component: Layout,
    redirect: '/info/detail',
    name: 'Info',
    hidden: true,
    children: [{
      path: 'detail',
      component: () => import('@/views/info/info')
    }]
  },

  {
    path: '/student',
    component: Layout,
    redirect: '/student/list',
    name: '学生管理',
    meta: {
      roles: ['admin', 'editor'],
      title: '学生管理',
      icon: 'example'
    },
    children: [{
        path: 'list',
        name: '学生列表',
        component: () => import('@/views/student/StudentList'),
        meta: {
          title: '学生列表',
          icon: 'table'
        }
      },
      {
        path: 'add',
        name: '新增学生',
        component: () => import('@/views/student/AddStudentDialog'),
        meta: {
          title: '新增学生',
          icon: 'tree'
        },
        hidden: true
      }
    ]
  },

  {
    path: '/grade',
    component: Layout,
    redirect: '/grade/grade',
    name: '班级管理',
    alwaysShow: true, //一直显示根路由
    meta: {
      roles: ['admin', 'editor'],
      title: '班级管理',
      icon: 'example'
    },
    children: [{
      path: 'grade',
      name: '班级列表',
      component: () => import('@/views/grade/index'),
      meta: {
        title: '班级列表',
        icon: 'form'
      }
    }]
  },

  {
    path: '/dormitory',
    component: Layout,
    redirect: '/dormitory/building',
    name: '宿舍管理',
    meta: {
      roles: ['admin', 'editor'],
      title: '宿舍管理',
      icon: 'nested'
    },
    children: [{
        path: 'building',
        component: () => import('@/views/dormitory/building'), // Parent router-view
        name: '楼栋管理',
        meta: {
          title: '楼栋管理'
        },
      },
      {
        path: 'dormitory',
        component: () => import('@/views/dormitory/dormitory'),
        meta: {
          title: '寝室管理'
        }
      }
    ]
  },

  {
    path: '/dormitoryMaster',
    component: Layout,
    name: '宿管管理',
    redirect: '/dormitoryMaster/list',
    meta: {
      roles: ['admin', 'editor'],
      title: '宿管管理',
      icon: 'nested'
    },
    children: [{
      path: '/list',
      component: () => import('@/views/dormitoryMaster/dormitoryMaster'),
      meta: {
        title: '宿管管理',
        icon: 'link'
      }
    }]
  },

  {
    path: '/leave',
    component: Layout,
    redirect: '/leave/leaving',
    name: '请假申请',
    meta: {
      roles: ['admin', 'editor'],
      title: '请假申请',
      icon: 'nested'
    },
    children: [{
        path: '/leaving',
        component: () => import('@/views/leave/leaving'),
        meta: {
          title: '进行中',
          icon: 'link'
        }
      },
      {
        path: '/all',
        component: () => import('@/views/leave/leaveList'),
        meta: {
          title: '请假记录',
          icon: 'link'
        }
      }
    ],

  },

  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRouterMap
})
